from itsdangerous import TimedJSONWebSignatureSerializer
from django.conf import settings

class SecretOauth(object):
    def __init__(self):
        self.Serializer = TimedJSONWebSignatureSerializer(secret_key=settings.SECRET_KEY, expires_in=60*15*20)

    def dumps(self,content_dict):
        result = self.Serializer.dumps(content_dict)

        return result.decode()
    def loads(self,access_token):
        try:
            result = self.Serializer.loads(access_token)

        except:
            return None
        return result

